#!/usr/bin/python3
# -*- coding: utf-8 -*-
#======================================#
# @Author   : duanqizhong
# @time     : 2022-3-12 11:49
# @file     : api_host
# @Software : PyCharm
#======================================#
from flask import Blueprint, request, make_response, jsonify

from apps.api.common_func import all_host
from apps.config import ERROR_RESPONSE

host_bp = Blueprint("host", __name__, url_prefix="/api/v1/host")


@host_bp.route("/info", methods=("GET",))
def host():
    try:
        args = request.args
        host = args["host"]
        infos = all_host(host)
        return make_response(jsonify(infos))
    except Exception as e:
        ERROR_RESPONSE["msg"] = str(e)
    return make_response(jsonify(ERROR_RESPONSE))